package kitwee.com.kanpad.bean;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import kitwee.com.kanpad.R;

/**
 * @author GanQuan
 * @date 2018/1/25
 * kitwee.com.kanpad.bean
 */

public class RealTimeAdapter extends RecyclerView.Adapter<RealTimeAdapter.ViewHolder> {


    private Context context;
    private List<RealTimeData.DataBean> realTimeBeanList;

    public RealTimeAdapter(Context context, List<RealTimeData.DataBean> realTimeBeanList) {
        this.context = context;
        this.realTimeBeanList = realTimeBeanList;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.real_time_item, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.status.setText(""+ realTimeBeanList.get(position).getStatus());
        holder.projectName.setText(""+ realTimeBeanList.get(position).getProject());
        holder.realData.setText(""+ realTimeBeanList.get(position).getRealValue());
        holder.standard.setText(""+ realTimeBeanList.get(position).getStandardValue());
        holder.unit.setText(""+ realTimeBeanList.get(position).getUnit());
    }

    @Override
    public int getItemCount() {
        return realTimeBeanList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.status)
        TextView status;
        @BindView(R.id.project_name)
        TextView projectName;
        @BindView(R.id.real_data)
        TextView realData;
        @BindView(R.id.standard)
        TextView standard;
        @BindView(R.id.unit)
        TextView unit;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }

    }


}
